#include "netcli.hpp"
#include "nlohmann/json.hpp"
#include <arpa/inet.h>
#include <cstring>
#include <iostream>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>

#define BUFFER_SIZE 1024

int main()
{
    int cnt = 0;
    char buffer[BUFFER_SIZE];
    char ip[16] = "127.0.0.1";
    nlohmann::json obj;

    obj["type"] = 0;
    obj["time"] = "2024-09-30 12:00:00";
    obj["position"] = { 0, 10, 640, 480 };

    std::string str = obj.dump();

    netcli cli(ip, 8080);
    cli.netsend(str.data(), str.length());
    memset(buffer, 0, BUFFER_SIZE);
    cli.netrecv(buffer, BUFFER_SIZE);
    std::cout << buffer << std::endl;

    return 0;
}
